package com.hut.oa.model.bean;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name="notes_dir")
public class NoteDir {

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="not_dir_id")
	private Integer id;//笔记目录id
	
	@Column(name="not_dir_name")
	private String	name;//笔记目录名称
	
	@JoinColumn(name="user_id",nullable=false)
	@ManyToOne
	@JsonIgnore
	private User user;//用户id

	@OneToMany(mappedBy="dir",fetch = FetchType.EAGER)
	@JsonIgnore
	@Transient
	private List<Notes> note;
	
	public NoteDir(){
		
	}
	public NoteDir(String name, User user) {
		this.name = name;
		this.user = user;
	}
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public String toString() {
		return "NoteDir [id=" + id + ", name=" + name + "]";
	}
	
}
